package com.visionet.school.app.web.common.utils;

import net.coobird.thumbnailator.Thumbnails;

import java.io.FileNotFoundException;

/**
 * Created by hxpeng on 2017/4/23.
 */
public class ThumbnailUtils {

    public static final int WIDTH = 200 ;
    public static final int HEIGHT = 200 ;

    public static void thumbnail(String imgPath, String savePath) throws FileNotFoundException {
        try {
            Thumbnails.of(imgPath)
                    .outputFormat("jpg")
                    .size(WIDTH, HEIGHT)
                    .toFile(savePath);
        } catch(Exception e) {
            e.printStackTrace() ;
        }
    }


//    public static void main(String[] args){
//        String saveFilePath = "C:/Users/hxpeng/Desktop/";
//        if(saveFilePath.charAt(saveFilePath.length()-1) == '/'){
//            saveFilePath = saveFilePath.substring(0,saveFilePath.length()-1);
//            System.out.println(saveFilePath);
//        }
//        String folder = saveFilePath.substring(saveFilePath.lastIndexOf("/") + 1, saveFilePath.length());
//        System.out.println(folder);
//    }

}
